package com.ruoyi.web.controller.system;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.SysCategory;
import com.ruoyi.system.service.SysCategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api")
@Api(tags = "类别管理")
public class CategoryController extends BaseController {
    @Autowired
    SysCategoryService service;
    @ApiOperation("类别树")
    @GetMapping("/all")
    public AjaxResult queryAll(){
        List list=service.queryAll();
        return success(list);
    }
    @ApiOperation("类别列表")
    @GetMapping("/categoryList")
    public AjaxResult queryList(){
        List list=service.querylist();
        return success(list);
    }
    @ApiOperation("插入类别")
    @PostMapping("/add")
    public AjaxResult insert(@RequestBody SysCategory category){
        int rs=service.insert(category);
        return rs>0?success("插入成功"):error("插入失败");

    }

}
